#!/usr/bin/env python
#coding=utf-8
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from sso.Member import verify_mail
from sso.Config import Config 
from sso.response_code import HTTP_RESPONSE_CODE
class MainHandler(webapp.RequestHandler):
  def get(self):
    mail = self.request.get('mail')
    sign_virtify = self.request.get('v')
    status = verify_mail(mail,sign_virtify)
    if status == HTTP_RESPONSE_CODE['HTTP_RESPONSE_VALIDATE_NO']:
        msg = "VALIDATE_NO"
    elif status == HTTP_RESPONSE_CODE['HTTP_RESPONSE_EMAIL_NOT_EXISTS']:
        msg = 'EMAIL_NOT_EXISTS'
    elif status == HTTP_RESPONSE_CODE['HTTP_RESPONSE_VALIDATE_OK']:
        return_url = Config.get_instance()['mail']['return_url']
        msg = 'VALIDATE OK <a href="%s">click to return member center</a>' % return_url
    self.response.out.write(msg)
app = webapp.WSGIApplication([('/verify_mail', MainHandler)], debug=True)
                                    
def main():
  run_wsgi_app(app)
if __name__ == '__main__':
  main()
